package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.supports.PageData;
import com.chinatechstar.component.commons.utils.CurrentUserUtils;
import com.zjcode.cdcer.model.CerTablefieldShowstatus;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.CerTablefieldShowstatusService;
import com.zjcode.cdcer.service.SysUserService;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:SystemInitController
 * @功能：详细数据上报
 * @author：wlei
 * @日期：2022/7/9-02:00
 **/
@RestController
@Slf4j
@RequestMapping("/v1/detaileddatareporting/")
public class DetailedDataReportingController extends BaseController {

    @Autowired
    private CerTablefieldShowstatusService cerTablefieldShowstatusService;


    /**
     * 返回所有可以用于显示的表字段信息
     *
     * @return
     */
    @PostMapping("listAllTableColumn")
    public JsonObj listAllTableColumn(@RequestBody PageData pageData, HttpServletRequest request) {

        //String userId = (String) pageData.get("user");
        //String userExtFlag = sysUserService.findUserExtFlag(userId);
        //log.info("userExtFlag: {}", userExtFlag);
        List<CerTablefieldShowstatus> colums = cerTablefieldShowstatusService.selectAllTableColumnBy(
            "import03");

        Map<String, Object> data = new HashMap<>();
        data.put("colums", colums);

        return JsonObj.success(data);
    }

    @PostMapping("listAllTableColumn4Office")
    public JsonObj listAllTableColumn4Office(@RequestBody PageData pageData,
                                             HttpServletRequest request) {
        List<CerTablefieldShowstatus> colums = cerTablefieldShowstatusService.selectAllTableColumnBy(
            "import04");

        Map<String, Object> data = new HashMap<>();
        data.put("colums", colums);

        return JsonObj.success(data);
    }

}
